import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

import { UseGlobal } from './use-global'
import element from './use-global/use-element'

UseGlobal({
  Vue
})
require('./use-global/mock')
Vue.config.productionTip = false;

Vue.use(element)


router.beforeEach((to, from, next) => {
  //NProgress.start();
  if (to.path == '/login') {
    sessionStorage.removeItem('user');
  }
  let user = JSON.parse(sessionStorage.getItem('user'));
  console.log(user)
  if (!user && to.path != '/login') {
    next({ path: '/login' })
  } else {
    next()
  }
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
